using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace BlockOS.Client
{
    public class PauseDialog : BaseInputActionMapWindow
    {
        [SerializeField]
        private PausePanel pausePanel;

        private bool isClosing = false;
        protected override void Awake()
        {
            inputs["Close"].performed += ctx =>
            {
                Close();
            };
        }

        public override void OnShow()
        {
            isClosing = false;
        }

        public override void OnHide()
        {
            
        }

        public void Close()
        {
            if (!isClosing) StartCoroutine(AnimateClose());
        }

        private IEnumerator AnimateClose()
        {
            isClosing = true;
            yield return pausePanel.AnimateHide(0.2f);
            manager.PopWindow(true);
        }

        public void Back()
        {
            GameClient.Instance.SetStage(new MenuStage());
        }
    }
}
